package com.vinjogames.entities;

import javax.microedition.khronos.opengles.GL10;

import com.vinjogames.gfx.Gun;
import com.vinjogames.gfx.Image;
import com.vinjogames.util.GameConVars;
import com.vinjogames.util.Preferences;

public class Turret extends AttackObject {
	int buildCost;
	int buildTime;
	float mRotation;
	int mType;

	public void clearInfo() {
		
	}
	
	public Turret() {
		super(GameConVars.OBJECT_TURRET, GameConVars.TURRET_COST_PER_ATTACK);
	}
	
	public Turret(int type, Player p, float x, float y) {
		this();
		mGLWidth = 3;
		mGLHeight = 3;
		mImage = new Image(GameConVars.GRAPHIC_TURRETS[0],mGLWidth,mGLHeight);
		mGun = new Gun(GameConVars.GRAPHIC_GUNS[8], Gun.TURRET, Gun.TURRET_LENGTH);
		mLocation.set(x,y);
		myPlayer = p;
		direction = myPlayer.isFirstPlayer();
		mType = type;
	}
	
	public void draw(GL10 gl){
		gl.glPushMatrix();
		
		rotate(mRotation);
		
		gl.glTranslatef(0, getGLHeight()*.5f, 0);

		getImage().setFlip(!direction);
		mGun.getImage().setFlip(!direction);

		super.draw(gl);
		mGun.draw(gl,mLocation, mRotation);
		
		gl.glPopMatrix();

		drawBars(gl, mLocation.x, mLocation.y + mGLHeight/2, mGLWidth, mGLHeight, health, 0,1,0,1);
		if(Preferences.getDebugSetting())drawCollisionBox(gl);
	}
	
	public void turnIntoType(int type, Player p, float x, float y) {
		mType = type;
		myPlayer = p;
		mLocation.set(x,y);
	}
	
}
